package arefjell.name.valutakalkulator2;

import android.widget.*;
import android.content.*;
import android.view.*;
import android.view.View.OnClickListener;

public class KeypadAdapter extends BaseAdapter {
	private Context mContext;
	
	private OnClickListener mOnbuttonClick;
	
	public KeypadAdapter(Context c){
		mContext = c;
	}
	
	public void setOnButtonClickListener(OnClickListener listener){
		mOnbuttonClick = listener;
	}

	public int getCount() {
		return mButtons.length;
	}

	public Object getItem(int position) {
		return mButtons[position];
	}

	public long getItemId(int arg0) {
		return 0;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		Button btn = new Button(mContext);
		KeypadButton keypadButton = mButtons[position];
		btn.setOnClickListener(mOnbuttonClick);
		btn.setTag(keypadButton);
		btn.setText(mButtons[position].getText());
		return btn;
	}
	
	private KeypadButton[] mButtons = { KeypadButton.seven, KeypadButton.B, KeypadButton.C, KeypadButton.D, 
			KeypadButton.E, KeypadButton.F,KeypadButton.G, KeypadButton.H, KeypadButton.I, 
			KeypadButton.J, KeypadButton.K};
	
}